package user

import (
	util2 "gitee.com/binny_w/go-util/v2"
	"github.com/gin-gonic/gin"
)

func infoFixer(_ *gin.Context, row *util2.MysqlRow) error {
	row.Drop("pasd")
	if row.Has("role") && row.Has("id") {
		row.Set("role", correctRole(uint64(row.ToInt64("id")), row.ToStr("role"), false))
	}
	if row.Has("avatar") {
		if ss := row.ToStrings("avatar"); len(ss) > 1 {
			row.Set("avatar_bucket", ss[0])
			row.Set("avatar_key", ss[1])
			row.Drop("avatar")
		}
	}
	if row.Has("signature") {
		if ss := row.ToStrings("signature"); len(ss) > 1 {
			row.Set("signature_bucket", ss[0])
			row.Set("signature_key", ss[1])
			row.Drop("signature")
		}
	}
	return nil
}
